<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>表单元素样式控制</title>
    <link rel="stylesheet" href="/static/css/my-demo.css">
    <style>

        form > input:disabled {
            background-color: red;
        }

        form > input:enabled {
            background-color: green;
        }

        form > input:checked + label {
            color: yellow;
        }

        /**
        说明:
            1. 选中第一个p, 设置首字母大写;
        */
        #cont > p:nth-of-type(1):first-letter {
            color: red;
        }

        /**
        说明:
            1. 选中p子元素从第三个开始的, 然后设置第一行的样式.
         */
        #cont > p:nth-of-type(n+3):first-line {
            color: red;
        }

        .simulation-input {
            border: solid 1px black;
            width: fit-content;
            border-radius: 3px;
            display: inline;
            margin-left: 5px;
        }

        .simulation-input > input[type='text'] {
            border: none;
            outline: none;
            margin-left: 2px;
        }

        .simulation-input > input + span:after {
            width: 30px;
            content: "@qq.com";
            background-color: green;
            display: inline;
        }

    </style>
</head>
<body>
<div>
    <h1>一. form表单元素样式控制</h1>
    <form>
        <label for="name">姓名</label>
        <input id="name" type="text" disabled="disabled" />
        <label for="age">年龄</label>
        <input id="age" type="text" />
        <hr/>
        <input type="radio" name="sex" id="boy" />
        <label for="boy">男</label>
        <input type="radio" name="sex" id="girl" />
        <label for="girl">女</label>
        <button>save</button>
    </form>
    <h2>1.1 使用div模拟表单元素</h2>
    <label for="email">email:</label>
    <div class="simulation-input">
        <input id="email" type="text" maxlength="9" />
        <span></span>
    </div>
</div>
<div id="cont">
    <h1>二. p标签内容控制</h1>
    <h2>2.1 选中段的第一个字符</h2>
    <p>我爱你中国1</p>
    <p>我爱你中国2</p>
    <h2>2.2 选中段的第一行</h2>
    <p>我很爱中国1</p>
    <p>我很爱中国2</p>
</div>
</body>
</html>